Copyright: Copyright 1995 Tomasz Stanczak


Introduction
RtDbGenID Ver. 1.01

Copyright 1995 Tomasz Stanczak

Compuserve: 100735,3273

RtDbGenID is a non-visual component which implements a unique number generator. All values will

be saved into a table in database you work with. Every access which generates a new value locks this

table and saves the generated value before releasing control, so that other users can safely run it

parallel through the network. SQL queries as 'SELECT MAX(...)+1 FROM...' are a bit dangereous,

because many users can theoretically execute this query at the same time and get the same results.

Databases which support referential integrity can get over it, if the value is supposed for a field

defined as unique, but even at the minimum it would rise an exception. dBase knows nothing about

real uniqueness and in this case it can cause severe data errors.

TRtDbGenID

Registration

Licence

Warranty

Support

Technical Notes

Revision History


TRtDbGenID

Properties	Methods

To make this component work at the minimum two properties must be set: Table property must point to a valid table from the current database and IDName property must give a name to a field where ID that is going to be used should be saved. Both of them dont need to exist, setting OnNewCreate property to True causes the component to create both the table and the field in the table if they dont exist. New ID values are generated on every call to NewValue method and are saved in the database. CurrentValue returns the last ID value that has been generated. When adding a large number of IDs is anticipated then AddValue method adds a constant number to the ID, which is faster then calling NewValue many times.


OnAccessClose

Declaration

property OnAccessClose: Boolean;

Description

By default after every access the ID table be closed. This is to make sure that changes are written into database. To speed things up you can set thos property to false, but then you have to close the table yourself.


OnNewCreate

Declaration

property OnNewCreate: Boolean;

Description

If this property is set True and it is so by default, then a field will be created for every accessed ID if it dont exist. Otherwise it must be present or an exception will be raised.


IDName

Declaration

property IDName: string;

Description

This is a name of the ID field. If this field doesnt exist and OnNewCreate is set True, the table would be restructured, otherwise an exception will be raised.


Table

Declaration

property Table: TTable;

Description

This is your database table, where all IDs will be saved. If it doesnt exist and the OnNewCreate property has been set True then it will be created, otherwise an exception will be raised.


CheckValue

Declaration

function CheckValue(const Database, TableName, FieldID: string): longint;

Description

This public method looks for a biggest Field ID value from TableName in Database using following SQL query:

SELECT MAX(FieldID) FROM TABLENAME

The result of the query, which is also functions result, is compared with the current IDs value, then the ID will be set to the bigger of the two.


CurrentValue

Declaration

function CurrentValue: longint;

Description

This public method returns the aktual ID value as saved in the database. It shouldnt be used to get the ID because it returns the same value for all other users in network, too.


NewValue

Declaration

function NewValue: longint;

Description

This method generates new ID values. It saves each new generated value into the database before releasing locks and returning to the caller, so it shouldnt be possible to have a confllict with other users.


AddValue

Declaration

function AddValue(Value: longint): longint;

Description

Allows to change the current ID value by <Value>. It can be used if a range of new values is needed. This is much faster then calling the NewValue method many times. After that the generated values can be distributed manually.


SetValue

Declaration

procedure SetValue(Value: longint);

Description

Allows to set the current ID to any value. It should be used with care, because the new value can violate the uniqness of the ID. This is a reason why this function is made protected, in order to use it you must first inherit the TRtDbGenID and publish this method.


Registration

Product	Price	s&h
RtDbGenID	$10 (15 DM)	2$ (3 DM)
RtControls	$39 (60 DM)	2$ (3 DM)

Only following payment methods will be accepted:

Compuserve: GO SWREG

ID# 7406 RtDbGenID alone

ID# 7197 RtControls

Checks: Only checks drawn on a US bank valued in US$ or drawn on a German bank and valued in DM will be accepted. The checks should be made payable to Tomasz Stanczak. Please let us time after sending check, we cannot send you our product before the money is transferred.

Please fill in the Order Form and send with a payment to:

Tomasz Stanczak

Hardenbergstr. 8

31275 Lehrte

Germany

Credit Card Orders: You can order with MC, Visa, Amex, or Discover from Public (software) Library by calling 800-2424-PsL or 713-524-6394 or by FAX to 713-524-6398 or by CIS Email to 71355,470. You can also mail credit card orders to PsL at P.O.Box 35705, Houston, TX 77235-5705.

THE ABOVE NUMBERS ARE FOR CREDIT CARD ORDERS ONLY.

THE AUTHOR OF THIS PROGRAM CANNOT BE REACHED AT THESE NUMBERS.

Any questions about the status of the shipment of the order, refunds, registration options, product details, technical support, volume discounts, dealer pricing, site licenses, non-credit card orders, etc, must be directed to Tomasz Stanczak:

CIS: 	100735,3273

Internet:	100735.3273@compuserve.com

WWW:	http://ourworld.compuserve.com/homepages/tomasz

To order please specify Item# 14429, RtControls Delphi VCL Pack, price $39 plus s&h $2 (e-mail) or $4 (Europe) or $6 overseas.

To insure that you get the latest version, PsL will notify us the day of your order and we will ship the product directly to you.

Shipping:

Currently only e-mail shipping is supported, so please always state your e-mail address!. In the future post shipping including printed documentation will be possible (no promise!).

Registered users will receive components full source code. Contact the author for multi-user discounts and site licenses.


Order Form

Name (block

letters please):	______________________________________________________

Company Name:	______________________________________________________

Street Address:	______________________________________________________

______________________________________________________

City, State,

Zip Code:	______________________________________________________

Country:	______________________________________________________

Phone Number:	______________________________________________________

E-Mail Address:	______________________________________________________

Product Name	Quantity	Price

__________________________________________________________________

__________________________________________________________________

__________________________________________________________________

__________________________________________________________________

Shipping__________________________________________________________

Total Fee_________________________________________________________


Technical Notes

The shareware version of this component runs only if Delphi will be found in memory.


Licence

Program and documentation Copyright 1995 Tomasz Stanczak (RiT).  Source code and design time use licensed for a single registered developer. Unlimited royalty-free distribution permitted as part of an EXE file, provided that internal copyright notice is not altered or removed.

Non-registered users may use the software to test it without any time frame, as long as they use the shareware version of RtDbGenID. A limited license is granted to copy and distribute shareware version of RtDbGenID only for the trial use of others.


Warranty

LIMITED WARRANTY

EXCEPT AS PROVIDED ABOVE, AUTHOR DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE PRODUCT.  SHOULD THE PROGRAM PROVE DEFECTIVE, THE PURCHASER ASSUMES THE RISK OF PAYING THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION AND ANY INCIDENTAL OR CONSEQUENTIAL DAMAGES.  IN NO EVENT WILL AUTHOR BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING WITHOUT LIMITATION DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION AND THE LIKE) ARISING OUT OF THE USE OR THE INABILITY TO USE THIS PRODUCT EVEN IF AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


Support

Support is available from the author via Compuserve Mail to 100735,3273 , Internet Mail to 100735.3273@compuserve.com or http://ourworld.compuserve.com/homepages/tomasz. Currently there is no postal, telephone, or fax support. All support is on a "best effort" basis, and no promise is made that all questions can be answered, problems solved, features added nor bugs exterminated.


Revision History

1.01	An error when adding an ID field has been corrected.
	CheckValue method is now a function returning the lowest possible value for an ID.
	AddValue and SetValue methods have been added.
1.00	this is the intial version.


Properties

OnAccessClose	IDName
OnNewCreate	Table


Methods

Create	CurrentValue
Destroy	NewValue
AddValue	SetValue
CheckValue